using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
    #region CustomerAttendee

    /// <summary>
    /// CustomerAttendee object for NHibernate mapped table 'CustomerAttendee'.
    /// </summary>
    [Serializable]
    public class CustomerAttendee : System.IComparable
    {
        #region Member Variables

        protected int _id;
        protected string _nameCN;
        protected string _nameEN;
        protected string _title;
        protected string _titleEN;
        protected string _company;
        protected string _companyEN;
        protected bool _isAttended;
        protected bool _gender;
        protected string _remark;
        protected int _isExisted;
        protected int _isNeedEntertainment;
        protected int _isNeedGift;
        protected Nullables.NullableDateTime _clearDate;
        protected DicItem _affects;
        protected DicItem _responsibility;
        protected CustomerInfo _customerInfo;
        protected static String _sortExpression = "Id";
        protected static SortDirection _sortDirection = SortDirection.Ascending;

        #endregion

        #region Constructors

        public CustomerAttendee() { }

        public CustomerAttendee(string nameCN, string nameEN, string title, string titleEN, string company, string companyEN, bool isAttended, bool gender, string remark, int isExisted, int isNeedEntertainment, int isNeedGift, Nullables.NullableDateTime clearDate, DicItem affects, DicItem responsibility, CustomerInfo customerInfo)
        {
            this._nameCN = nameCN;
            this._nameEN = nameEN;
            this._title = title;
            this._titleEN = titleEN;
            this._company = company;
            this._companyEN = companyEN;
            this._isAttended = isAttended;
            this._gender = gender;
            this._remark = remark;
            this._isExisted = isExisted;
            this._isNeedEntertainment = isNeedEntertainment;
            this._isNeedGift = isNeedGift;
            this._clearDate = clearDate;
            this._affects = affects;
            this._responsibility = responsibility;
            this._customerInfo = customerInfo;
        }

        #endregion

        #region Public Properties

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public string NameCN
        {
            get { return _nameCN; }
            set
            {
                if (value != null && value.Length > 200)
                    value = value.Substring(0, 200);
                _nameCN = value;
            }
        }

        public string NameEN
        {
            get { return _nameEN; }
            set
            {
                if (value != null && value.Length > 200)
                    value = value.Substring(0, 200);
                _nameEN = value;
            }
        }

        public string Title
        {
            get { return _title; }
            set
            {
                if (value != null && value.Length > 200)
                    value = value.Substring(0, 200);
                _title = value;
            }
        }

        public string TitleEN
        {
            get { return _titleEN; }
            set
            {
                if (value != null && value.Length > 200)
                    value = value.Substring(0, 200);
                _titleEN = value;
            }
        }

        public string Company
        {
            get { return _company; }
            set
            {
                if (value != null && value.Length > 200)
                    value = value.Substring(0, 200);
                _company = value;
            }
        }

        public string CompanyEN
        {
            get { return _companyEN; }
            set
            {
                if (value != null && value.Length > 200)
                    value = value.Substring(0, 200);
                _companyEN = value;
            }
        }

        public bool IsAttended
        {
            get { return _isAttended; }
            set { _isAttended = value; }
        }

        public bool Gender
        {
            get { return _gender; }
            set { _gender = value; }
        }

        public string Remark
        {
            get { return _remark; }
            set
            {
                if (value != null && value.Length > 500)
                    value = value.Substring(0, 500);
                _remark = value;
            }
        }

        public int IsExisted
        {
            get { return _isExisted; }
            set { _isExisted = value; }
        }

        public int IsNeedGift
        {
            get { return _isNeedGift; }
            set { _isNeedGift = value; }
        }

        public int IsNeedEntertainment
        {
            get { return _isNeedEntertainment; }
            set { _isNeedEntertainment = value; }
        }

        public Nullables.NullableDateTime ClearDate
        {
            get { return _clearDate; }
            set { _clearDate = value; }
        }

        public DicItem Affects
        {
            get { return _affects; }
            set { _affects = value; }
        }

        public DicItem Responsibility
        {
            get { return _responsibility; }
            set { _responsibility = value; }
        }

        public CustomerInfo CustomerInfo
        {
            get { return _customerInfo; }
            set { _customerInfo = value; }
        }

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
        #endregion

        #region IComparable Methods
        public int CompareTo(object obj)
        {
            if (!(obj is CustomerAttendee))
                throw new InvalidCastException("This object is not of type CustomerAttendee");

            int relativeValue;
            switch (SortExpression)
            {
                case "Id":
                    relativeValue = this.Id.CompareTo(((CustomerAttendee)obj).Id);
                    break;
                case "NameCN":
                    relativeValue = (this.NameCN != null) ? this.NameCN.CompareTo(((CustomerAttendee)obj).NameCN) : -1;
                    break;
                case "NameEN":
                    relativeValue = (this.NameEN != null) ? this.NameEN.CompareTo(((CustomerAttendee)obj).NameEN) : -1;
                    break;
                case "Title":
                    relativeValue = (this.Title != null) ? this.Title.CompareTo(((CustomerAttendee)obj).Title) : -1;
                    break;
                case "TitleEN":
                    relativeValue = (this.TitleEN != null) ? this.TitleEN.CompareTo(((CustomerAttendee)obj).TitleEN) : -1;
                    break;
                case "Company":
                    relativeValue = (this.Company != null) ? this.Company.CompareTo(((CustomerAttendee)obj).Company) : -1;
                    break;
                case "CompanyEN":
                    relativeValue = (this.CompanyEN != null) ? this.CompanyEN.CompareTo(((CustomerAttendee)obj).CompanyEN) : -1;
                    break;
                case "IsAttended":
                    relativeValue = (this.IsAttended != Convert.ToBoolean(null)) ? this.IsAttended.CompareTo(((CustomerAttendee)obj).IsAttended) : -1;
                    break;
                case "Gender":
                    relativeValue = (this.Gender != Convert.ToBoolean(null)) ? this.Gender.CompareTo(((CustomerAttendee)obj).Gender) : -1;
                    break;
                case "Remark":
                    relativeValue = (this.Remark != null) ? this.Remark.CompareTo(((CustomerAttendee)obj).Remark) : -1;
                    break;
                case "IsExisted":
                    relativeValue = (this.IsExisted != Convert.ToInt32(null)) ? this.IsExisted.CompareTo(((CustomerAttendee)obj).IsExisted) : -1;
                    break;
                case "ClearDate":
                    relativeValue = (this.ClearDate != null) ? this.ClearDate.CompareTo(((CustomerAttendee)obj).ClearDate) : -1;
                    break;
                default:
                    goto case "Id";
            }
            if (CustomerAttendee.SortDirection == SortDirection.Ascending)
                relativeValue *= -1;
            return relativeValue;
        }
        #endregion
    }

    #endregion
}
